package com.stripe.input.view;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;



/**
 * File: ErrorTextListener
 * Author: 82149 Create: 2021/6/28 18:30
 * Changes (from 2021/6/28)
 * --------------------------------------------------
 * description:
 * ---------------------------------------------------
 */
public class ErrorTextListener implements StripeEditText.ErrorMessageListener{
    @NonNull
    private final TextView mTextHintView;

    ErrorTextListener(@NonNull TextView textInputLayout) {
        mTextHintView = textInputLayout;
    }

    @Override
    public void displayErrorMessage(@Nullable String message) {
        if (message == null) {
            mTextHintView.setText("");
            mTextHintView.setVisibility(View.GONE);
        } else {
            mTextHintView.setText(message);
            mTextHintView.setVisibility(View.VISIBLE);
        }
    }
}
